/**
 * @file       godemool/strpool.h
 * @brief      String pool.
 * @author     ben "boin" bonoeil
 * @date       2015-02
 */

/* Copyright (c) 2007-2015, ben "boin" bonoeil */

#ifndef GODEMOOL_STRPOOL_H
#define GODEMOOL_STRPOOL_H

#include <unordered_set>
#include <string>

namespace boin {

  /** Type for a string in the pool */
  typedef const char * wetstring;

  /** Very simple implementation of a string pool. */
  class StringPool: public std::unordered_set<std::string> {
    class Str { wetstring s; Str() { s = nullptr; }};
  public:
    /** Look up for a string in the pool or add it . */
    wetstring operator [](const std::string & key);

    /** A global pool. */
    static StringPool pool;
  };

}

#endif
